/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __QS_Utilities_H__
#define __QS_Utilities_H__

#include <QtCore/QDate>
#include <QtCore/QDateTime>

#include <QtCore/QString>
#include <QtCore/QStringList>

#include "Prerequisites.h"

namespace QSThink
{

	/*manipulate utilities
	*/
	class Utilities
	{
	public:
		static ExchangeType getExchangeBySymbol( int symbol );
		static ExchangeType getExchangeBySymbol(QString symbol );
		
		static int getDayOffset(QDate start,QDate end);
		//time seconds
		static int get2MinutesOffset(int seconds);

		static QString getDepositCurrencyTypeStr(DepositCurrencyType currency);

		static QString getDepositAccountTypeStr(DepositAccountType account);


		//
		static int subRestSeconds(int secondsFrom9);

		static int secondsFrom9To11_30();

		//is market open
		static bool exchangeOpen();

		static QString getCurrentDateTimeString();

		static QString getDateTimeStr( QDateTime &dateTime );

		static int getDaysFrom1900();

		static int getDaysFrom1900(QDate date);

		static QDate getDateByDay(int day);

		static QDate getDateByStr(QString dateStr);

		static QString getDateStr(QDate date);
		static QString getDateStrByDay(int day);


		//calculate time seconds passed from 9:00:00
		static int getSecondsFrom9(QString time);

		static QString getTimeStr(int time);


		static QString getTransTypeStr( int type );
		static int getStockChangeReasonByStr(QString type);

		static int getTransType(QString transType);
		static void convertFile(std::string name);

		//build transactions data download URL
		static QString buildTransQueryUrl( int symbol , int day );
		
		static QAbstractItemModel * loadSymbolModel();
		static QTime getTimeByStr( QString time );
		static int getDayByStr( QString dateStr );

		static QString getChangeReason(int type);

	};
}

#endif
